TopBar = function()
{
	Sprite.call(this);
	
	this.scoreText = this.createTextField("#000000");
	this.scoreText.setY(5);
	this.scoreText.setX(5);
	this.scoreText.text = "Score 0";
	this.addChild(this.scoreText);
	
	
	this.timeText = this.createTextField("blue");
	this.timeText.setY(5);
	this.timeText.setX(640);
	this.timeText.text= "Time 0";
	this.addChild(this.timeText);
	
	
	this.total = 0 ;
	var self =this ;
	this.timer = new Timer(1000,60);
	
	function timerHandler(e)
	{
		switch(e.getType())
		{
		case TimerEvent.TIMER:
			self.timeText.text = "Time "+(60-self.timer.getCurrentCount());
			break;
		case TimerEvent.TIMER_COMPLETE:
			self.timer.stop();
			self.timer.reset();
			GlobalDispatcher.getInstance().dispatchEvent( new GlobalEvent(GlobalEvent.GAME_OVER) );
			break ;
		}
	};
	this.timer.addEventListener( TimerEvent.TIMER , timerHandler );
	this.timer.addEventListener( TimerEvent.TIMER_COMPLETE , timerHandler );
	
	
	
	function scoreChangeHandler(e)
	{
		self.total+=e.score ;
		self.scoreText.text = "Score "+self.total ;
	};
	GlobalDispatcher.getInstance().addEventListener( ScoreEvent.SCORE_CHANGE , scoreChangeHandler );
	
	
	
	
	function gameStartHandler(e)
	{
		self.total = 0 ;
		self.scoreText.text = "Score "+self.total ;
		self.timeText.text = "Time 0" ;
		self.timer.start();
	};
	GlobalDispatcher.getInstance().addEventListener(  GlobalEvent.GAME_START , gameStartHandler );
	
	
	
	
	
	
	
};
FLASH.extend( TopBar , Sprite );

TopBar.prototype.createTextField = function( color )
{
	var txt = new TextField();
	txt.setX(120);
	txt.setY(80);
	txt.align = TextFieldAlign.LEFT ;
	txt.font="bold 25px Arial";
	txt.color = color ; //白色
	return txt ;
};